package ar.com.contable.ganancias.modelVO;

import java.util.ArrayList;
import java.util.List;

import ar.com.contable.ganancias.model.YearFolderModel;
import ar.com.contable.ganancias.util.LabelsBag;

public class YearModelVO  implements RowVO {

	private YearFolderModel model;
	private List<CategoryVO> categories = new ArrayList<CategoryVO>();
	
	/**
	 * Constructor.
	 * @param yearFolderModel
	 */
	public YearModelVO(YearFolderModel yearFolderModel) {
		this.setModel(yearFolderModel);
	}
	/**
	 * @return the model
	 */
	public YearFolderModel getModel() {
		return model;
	}
	/**
	 * @param model the model to set
	 */
	public void setModel(YearFolderModel model) {
		this.model = model;
	}
	/**
	 * @return the categories
	 */
	public List<CategoryVO> getCategories() {
		return categories;
	}
	/**
	 * @param categories the categories to set
	 */
	public void setCategories(List<CategoryVO> categories) {
		this.categories = categories;
	}
	@Override
	public boolean canModify(String property) {
		// TODO Auto-generated method stub
		return false;
	}
	
	@Override
	public String getValue(String property) {
		if (property.equals("detalle")){
			 return LabelsBag.getLabelText(this.getModel().toString());
		}
		return "";
	}
	@Override
	public void modify(String property, Object value) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public boolean hasChildren(Object element) {		
		return this.getCategories().size() > 0;
	}
	@Override
	public Object getParent(Object element) {
		// TODO Auto-generated method stub
		return null;
	}
	@Override
	public Object[] getChildren(Object parentElement) {
		// TODO Auto-generated method stub
		return this.getCategories().toArray();
	}

	@Override
	public String getColumnText(int columnIndex) {
		if (columnIndex==0){
			return this.toString();
		}
		return "";
	}
	public void refresh() {
		this.getModel().refresh();
		
	}
}
